//
//  main.swift
//  iSwift
//
//  Created by BunnyBlue on 9/7/15.
//  Copyright (c) 2015 BunnyBlue. All rights reserved.
//

import Foundation

print("Hello, World!")
let int1=Int.max
print(int1)
let decimalInteger = 17
let binaryInteger = 0b10001 // 二进制的17
let octalInteger = 0o21 // 八进制的17
let hexadecimalInteger = 0x11 // 十六进制的17

print(decimalInteger)
print(binaryInteger)
//let cannotBeNegative: UInt8 = -1
//// UInt8 类型不能存储负数,所以会报错
//let tooBig: Int8 = Int8.max + 1
let orangesAreOrange = true
let turnipsAreDelicious = false
if orangesAreOrange{
}else{
}
let http404Error=(404,"page not found")

let (statusCode, statusMessage) = http404Error
print("The status code is \(statusCode)", terminator: "")
// 输出 "The status code is 404"
print("The status message is \(statusMessage)", terminator: "") // 输出 "The status message is Not Found"
let http200Status = (statusCode: 200, description: "OK")
print("The status code is \(http200Status.statusCode)")
// 输出 "The status code is 200"
print("The status message is \(http200Status.description)") // 输出 "The status message is OK"

let three = 3
let minusThree =  -three // minusThree 等于 -3
let plusThree = -minusThree // plusThree 等于 3, 或 "负负3"







let name = "world1"

if name == "world" {
    print("hello, world", terminator: "")
} else {
    print("I'm sorry \(name), but I don't recognize you", terminator: "")
}

for index in 1...5 {
    print("\(index) * 5 = \(index * 5)")
}
let names = ["Anna", "Alex", "Brian", "Jack"]
for i in 0..<names.count{
print("第 \(i + 1) 个人叫 \(names[i])\n", terminator: "")
}


///////////////

let allowedEntry = false
if (!allowedEntry) {
    print("ACCESS DENIED", terminator: "") }

var emptyString = "" // 空字符串字面量 
var anotherEmptyString = String() // 初始化方法

var airports = ["YYZ": "Toronto Pearson", "DUB": "Dublin"]
airports.updateValue( "xx", forKey: "xx")

func sayHello(say:String)->String{
    print(say);
    return say;
}
func minMax(array: [Int]) -> (min: Int, max: Int) { var currentMin = array[0]
    var currentMax = array[0]
    for value in array[1..<array.count] {
    if value < currentMin { currentMin = value
} else if value > currentMax { currentMax = value
    }
    }
    return (currentMin, currentMax)
}
